<template>
  <div>
    <div v-if="quanxian">
      <el-form ref="form" :model="form2" label-width="80px">
        <el-form-item label="姓名2">
          <el-input v-model="form2.name2"></el-input>
        </el-form-item>
        <el-form-item label="年龄2">
          <el-input v-model="form2.age2"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleSub">立即创建</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div v-else>
      <el-form ref="form" :model="form3" label-width="80px">
        <el-form-item label="姓名3">
          <el-input v-model="form3.name3"></el-input>
        </el-form-item>
        <el-form-item label="年龄3">
          <el-input v-model="form3.age3"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleSub">立即创建</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>


<script>
export default {
  data() {
    return {
      quanxian: window.localStorage.getItem("user"),
      form2: {
        name2: "",
        age2: ""
      },
      form3: {
        name3: "",
        age3: ""
      }
    };
  },
  methods: {
    handleSub() {
      if(this.quanxian){
        this.$emit("handleSub", this.form2);
      }else{
        this.$emit("handleSub", this.form3);
      }
    }
  }
};
</script>
